<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$title}</title>
<<<<<<< HEAD
    {css href="/static/index/css/bootstrap.min.css"}
    {css href="/static/index/css/reset.css"}
    {css href="/static/index/css/toastr.min.css"}
    <!--{css href="/static/index/css/foundation.min.css"}-->

</head>
<body>
    <div class="container">
        <div class="col-md-12 bg-primary p20">
            <h1>{$title}</h1>
            <hr>
            <a href="{:url('admin/man/index')}" class="btn btn-default">用户列表首页</a>
            <button class="btn btn-default" data-toggle="modal" data-target="#myModal">添加用户</button>
        </div>
        <div class="clearfix"></div>
        <div class="row mt50">
            <div class="col-md-6 ">
                <table class="table table-hover bg-info">
                    <tr>
                        <th>ID</th>
                        <th>NAME</th>
                        <th>SEX</th>
                        <th>ACTION</th>
                    </tr>
                    {volist name='list' id='v' mod='2'}
                    {eq name='mod' value='0'}
                    <tr>
                        <td>{$v.id}</td>
                        <td>{$v.name}</td>
                        <td>{$v.sex}</td>
                        <td>
                            <a href="/man/{$v.id}" class="btn btn-default btn-xs">查看用户详情</a>
                            <button  class="btn btn-primary btn-xs btn-edit" edit-id="{$v.id}" data-toggle="modal" data-target="#myModal">编辑</button>
                            <button  class="btn btn-danger btn-xs btn-del" data-id="{$v.id}">删除</button>
                        </td>
                    </tr>
                    {/eq}
                    {/volist}
                </table>
            </div>
            <div class="col-md-6">
                <table class="table table-hover bg-info">
                    <tr>
                        <th>ID</th>
                        <th>NAME</th>
                        <th>SEX</th>
                        <th>ACTION</th>
                    </tr>
                    {volist name='list' id='v' mod='2'}
                    {eq name='mod' value='1'}
                    <tr>
                        <td>{$v.id}</td>
                        <td>{$v.name}</td>
                        <td>{$v.sex}</td>
                        <td>
                            <a href="/man/{$v.id}" class="btn btn-default btn-xs">查看用户详情</a>
                            <button  class="btn btn-primary btn-xs btn-edit" edit-id="{$v.id}" data-toggle="modal" data-target="#myModal">编辑</button>
                            <button  class="btn btn-danger btn-xs btn-del" data-id="{$v.id}">删除</button>
                        </td>
                    </tr>
                    {/eq}
                    {/volist}
                </table>
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">添加用户</h4>
                    </div>
                    <div class="modal-body">
                        <form action="{:url('admin/man/save')}" method="post" enctype="multipart/form-data">
                            <!--<input type="hidden" name="_method" value="put">-->
                            <div class="form-group">
                                <label for="exampleInputEmail1">NAME</label>
                                <input type="text" name="username" class="form-control" id="exampleInputEmail1" placeholder="请输入用户名">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">Password</label>
                                <input type="password" name="pass" class="form-control" id="exampleInputPassword1" placeholder="请输入密码">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1"></label>Address
                                <select id="pro" name="pro"></select>
                                <select id="city" name="city"></select>
                                <select id="area" name="area"></select>
                                <select id="street" name="street"></select>
                            </div>
                            <div class="form-group">
                                <!--<label for="exampleInputFile">图片上传</label>-->
                                <input type="file" name="image[]"  multiple/> <br>
                            </div>
                            <button type="submit" class="btn btn-success">添加</button>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                </div>
            </div>
        </div><!--modal-->
    </div>
    <div>{:captcha_img()}</div>
    {js href="/static/index/js/jquery.min.js"}
    {js href="/static/index/js/bootstrap.js"}
    <!--{js href="/static/index/js/foundation.min.js"}-->
    <!--{js href="/static/index/js/toastr.min.js"}-->
    <script src="https://cdn.bootcss.com/toastr.js/2.1.2/toastr.min.js"></script>
    {block name="my.js"}
        <script>
            //绑定删除按钮
            $(function(){
                $('.btn-del').click(function(){
                    var del_id=$(this).attr('data-id');
                    var obj = $(this).parents('tr');
                    if(confirm('您确定要[ 删除 ]该用户吗?')){
                        delAjax(del_id,obj);
                    }

                });
            });
            //设置弹框参数
            toastr.options = {
                closeButton:true,//是否显示关闭按钮
                progressBar:true,//实时显示计时条
                timeOut:"3000",//自动关闭时间
                positionClass:"toast-bottom-left"
            };
            //AJAX请求删除
            function delAjax(id,obj)
            {
                $.ajax({
                    type:'delete',
                    url:'/man/'+id,
                    datatype:'json',
                    success:function(data){
                        //console.log(data);
                      if(data.status){
                          toastr.success(data.info);
                          obj.remove();
                      }else{
                          toastr.error('删除失败,请重试');
                      }
                    },
                    error:function(){
                        alert('删除失败');
                    }
                });
            }

            //添加用户
            $(function(){
                $('.btn-add').click(function(){

                });
            });


            //查询地址
            // 获取省份信息
            // 获取省份信息
            $.ajax({
                type: 'get',
                url: 'admin/man/getAddress',
                dataType: 'json',
                async: false, //同步请求
                success:function (data){
                    // 清空原先的数据
                    $('#pro').empty();
                    // 遍历省份数据
                    // console.log(data);
                    for (var i = 0; i < data.length; i++) {
                        $('<option value="'+data[i].id+'">'+data[i].name+'</option>').appendTo('#pro');
                    }
                },
                error:function (){
                    alert(' AJAX 执行失败!')
                }
            });

            // 绑定change事件
            $('#pro,#city,#area').change(function (){
                // 清空之后所有的select框的内容
                $(this).nextAll('select').show().empty();
                // 获取当前的value值
                var upid = $(this).val();
                // console.log(upid);
                // console.log($(this));
                // 保留 $(this)  变量
                var _this = $(this);

                // 请求下一级数据
                $.ajax({
                    type: 'get',
                    url: 'admin/man/getAddress',
                    data: "upid="+upid,
                    dataType: 'json',
                    success:function (data){
                        // 如果下一级没有查询到数据
                        if (!data) {
                            _this.nextAll('select').hide();
                            return;
                        }
                        // console.log($(this));
                        // console.log($(this).constructor);
                        // console.log($);
                        // console.log(_this);

                        // 填充下一级数据
                        for (var i = 0; i < data.length; i++) {
                            $('<option value="'+data[i].id+'">'+data[i].name+'</option>').appendTo(_this.next('select'));
                        }
                        // 自动触发之后的select 的change事件
                        _this.next('select').trigger('change');
                    }
                });
            });


            // 自动触发#pro的change事件
            $('#pro').trigger('change');


            //编辑
            $(function(){
               $('.btn-edit').click(function(){
                   var edit_id = $(this).attr('edit-id');
                   console.log(edit_id);
                   $('.modal-title').html('编辑用户');
               });
            });


        </script>
    {/block}
</body>
</html>
=======
</head>
<body>
    <h1>{$title}</h1>
    <hr>
    <!--冒号表示调用一个函数-->
    {:date('Y-m-d H:i:s')}

</body>
</html>


>>>>>>> div
